<?php
namespace common\models\banner;

use common\models\goods\Goods;
use Yii;
use yii\db\ActiveRecord;
use yii\behaviors\TimestampBehavior;
use common\enums\StatusEnum;
use common\helpers\RegularHelper;

/**
 * This is the model class for table "{{%banner}}".
 *
 */
class Banner extends ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return '{{%banner}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['title'], 'required'],
            [['type','relevance_id','sort','status','member_id','store_id'], 'integer'],
            [['title'], 'string', 'max' => 40],
            [['image','link'],'string','max'=>150],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'member_id'=>'商户id',
            'store_id'=>'店铺id',
            'title'=>'标题',
            'image'=>'图片地址',
            'type' => '类型',
            'relevance_id' => '关联id',
            'sort' => '排序',
            'status' => '状态',
            'link'=>'链接地址',
        ];
    }

    /**
     * 场景
     *
     * @return array
     */
    public function scenarios()
    {
        return [
//            'backendCreate' => ['goods_name', 'goods_code','goods_bar','goods_unit','gc_id','member_id','store_id'],
            'default' => array_keys($this->attributeLabels()),
        ];
    }

    /**
     * @return array
     */
//    public function behaviors()
//    {
//        return [
//            [
//                'class' => TimestampBehavior::class,
//                'attributes' => [
//                    ActiveRecord::EVENT_BEFORE_INSERT => ['created_at', 'updated_at'],
//                    ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at'],
//                ],
//            ],
//        ];
//    }
}
